﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_TH_LeftMenu : System.Web.UI.UserControl
{
    private DataSet objDataSet;
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadLoaiSanPham();
    }

    private void LoadLoaiSanPham()
    {
        LoaiSanPhamBUS objLoaiSP = new LoaiSanPhamBUS(TGDDConfiguration.DbConnectionString);
        try
        {
            objDataSet = objLoaiSP.SelectLoaiSanPhamAll();

            repLoaiSanPham.DataSource = objDataSet.Tables["SelectLoaiSanPhamAll"];
            repLoaiSanPham.DataBind();
        }
        catch (System.Exception e)
        {

        }
    }

    protected void repLoaiSanPham_ItemDataBound1(object sender, RepeaterItemEventArgs e)
    {
        RepeaterItem item = e.Item;
        if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
        {
            Repeater repNhaSanXuat = (Repeater)item.FindControl("repNhaSanXuat");
            DataRowView myDataRowView = ((DataRowView) item.DataItem);

            NhaSanXuatBUS objNSX = new NhaSanXuatBUS(TGDDConfiguration.DbConnectionString);
            objDataSet = objNSX.SelectNhaSanXuatByLoaiSanPham(int.Parse(myDataRowView.Row["id"].ToString()));
            repNhaSanXuat.DataSource = objDataSet;
            repNhaSanXuat.DataBind();
        }
    }
}
